package com.ylbh.modules.returntemplate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylbh.common.utils.PageDTO;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Query;
import com.ylbh.modules.returntemplate.entity.ShoppingApplySpeechBundle;
import com.ylbh.modules.returntemplate.mapper.ShoppingApplySpeechBundleMapper;
import com.ylbh.modules.returntemplate.service.ShoppingApplySpeechBundleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * 退换货模板
 * @author czx
 */
@Service("ShoppingApplySpeechBundleService")
public class ShoppingApplySpeechBundleServiceImpl extends ServiceImpl<ShoppingApplySpeechBundleMapper, ShoppingApplySpeechBundle> implements ShoppingApplySpeechBundleService {


    @Override
    public PageUtils queryReturnTemplate(PageDTO pageDTO) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("limit", pageDTO.getLimit().toString());
        map.put("page", pageDTO.getPage().toString());
        IPage<ShoppingApplySpeechBundle> page = this.page(
                new Query<ShoppingApplySpeechBundle>().getPage(map),
                new QueryWrapper<ShoppingApplySpeechBundle>()
                        .like(StringUtils.isNotBlank(pageDTO.getKeywords()),"content", pageDTO.getKeywords())
                        .orderByDesc("sort")
        );
        return new PageUtils(page);
    }
}
